<template>
  <div>
    <div class="Statistics">
      <div class="home-top">
        <div class="hometitle">会泽县钟屏派出所智慧警务系统</div>
      </div>
      <div class="StatisticsBody">
        <div class="StatisticsFlex">
          <div class="homeimg" v-if="isSubordinate" @click="returnScene">
            <img src="../assets/images/home1.png" alt="" />
          </div>
          <div class="StatisticsCont" v-if="!isSubordinate">
            <div>
              <i class="iconfont icon-xiaoqu"></i>
              <div class="StatisticsTit">总园区</div>
            </div>
            <div class="StatisticsNum">{{ dataSum.parkNum }}</div>
          </div>
          <div class="StatisticsCont">
            <div>
              <i class="iconfont icon-loudongguanli1"></i>
              <div class="StatisticsTit">总楼栋</div>
            </div>
            <div class="StatisticsNum">{{ dataSum.buildNum }}</div>
          </div>
          <div class="StatisticsCont">
            <div>
              <i class="iconfont icon-loudongguanli"></i>
              <div class="StatisticsTit">总单元</div>
            </div>
            <div class="StatisticsNum">{{ dataSum.unitNum }}</div>
          </div>
          <div class="StatisticsCont">
            <div>
              <i class="iconfont icon-kaihushu"></i>
              <div class="StatisticsTit">总户数</div>
            </div>
            <div class="StatisticsNum">{{ dataSum.roomNum }}</div>
          </div>
          <div class="StatisticsCont" style="margin-right: 0">
            <div>
              <i class="iconfont icon-shiyourenkou"></i>
              <div class="StatisticsTit">总人口</div>
            </div>
            <div class="StatisticsNum">{{ dataSum.population }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import Basicdata from "./data";
export default {
  name: "Head",
  props: {
    isSubordinate: {
      type: Boolean,
      default: false,
    },
    buildId: {
      type: String,
      default: "null",
    },
  },
  data() {
    return {
      formSeta: Basicdata.formSeta,
      dataSum: {},
    };
  },
  watch: {
    isSubordinate(newInit, oldInit) {
      console.log("isSubordinate" + oldInit + "变为" + newInit);
      if (this.isSubordinate == true) {
        this.getOneData();
      } else {
        this.getData();
      }
    },
  },
  mounted() {
    console.log();
    if (this.isSubordinate) {
      this.getOneData();
    } else {
      this.getData();
    }
  },
  methods: {
    getOneData() {
      this.$axios
        .getOneSum({
          id: this.buildId,
        })
        .then((res) => {
          this.dataSum = res.data;
        });
    },
    getData() {
      this.$axios.getSum().then((res) => {
        this.dataSum = res.data;
      });
    },
    returnScene() {
      this.$emit("returnScene", false);
    },
  },
};
</script>

<style lang="scss" scoped>
.home-top {
  height: 88px;
  width: 100%;
  background: #05172f;
  opacity: 1;
  z-index: 2;
  display: flex;
  justify-content: center;
  align-items: center;
}
.hometitle {
  font-size: 41px;
  font-weight: bold;
  color: #bfebf9;
}
.Statistics {
  position: absolute;
  top: 0;
  width: 100%;
  opacity: 1;
  z-index: 2;
  .StatisticsBody {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 24px;
    .StatisticsFlex {
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .homeimg {
      height: 45px;
      width: 45px;
      cursor: pointer;
      position: absolute;
      left: 82px;
    }
    .homeimg img {
      height: 45px;
      width: 45px;
    }
    .StatisticsCont {
      display: flex;
      justify-content: space-between;
      align-items: center;
      width: 260px;
      height: 106px;
      background: url("../assets/images/statisticsBg.png");
      background-repeat: no-repeat;
      padding: 0 25px;
      margin-right: 50px;
      i {
        color: #62edff;
        font-size: 36px;
      }
    }
    .StatisticsNum {
      color: #fff;
      font-size: 48px;
      font-weight: bold;
    }
    .StatisticsTit {
      color: #62edff;
      font-size: 20px;
    }
  }
}
</style>
